
%For fixed q, calculate solution without screening moral hazard, i.e., the
%second best case


iGridB=1000;
aBGrid=linspace(0,aBar,iGridB);
qB=q;

for i=1:iGridB
    
    aB=aBGrid(i);
    
    W=aB*phi;
    FB=mu-(gamma-r)*W*Agency-0.5*phi*aB^2;
    FB=FB/(r+Lambda-aB-qB);
    vFB(i)=FB;
    
end

[FB,ind]=max(vFB);
aB=aBGrid(ind);
WB=phi*aB;
lambdaB=Lambda-aB-qB;

cB=((gamma+lambdaB+delta)*WB+0.5*phi*aB^2)/(1+delta*FB);
VB=WB/(gamma+lambdaB+delta);
LB=mu/(r+lambdaB);
tauB=1/lambdaB;
betaB=cB/mu;
